<?php

namespace app\admin\controller;

use think\Db;
use think\Controller;
use Util\Sysdb;
use think\facade\Session;
use app\admin\model\Userlog;
use app\admin\model\Reimbursement;

class Index extends BaseAdmin
{
    //后台左侧列表 动态加载菜单 过滤权限
    public function index()
    {
        return view();
    }
    //后台主页welcome
    public function welcome()
    {
        return view();
    }
    public function console()
    {
        $log = new Userlog();
        $ment = new Reimbursement();
        $res = $log->order('logintime desc')->limit(0,10)->select();
        $weekVisits = $log->whereTime('create_time','today')->count();
        $sumWeekVisits = $log->count();
        $weekExpenditure = $ment->where('is_delete',0)->where('status',1)->whereTime('create_time','week')->value('sum(money)');
        $sumWeekExpenditure = $ment->where('is_delete',0)->where('status',1)->value('sum(money)');
        $monthExpenditure = $ment->where('is_delete',0)->where('status',1)->whereTime('create_time','month')->value('sum(money)');
        $sumMonthExpenditure = $ment->where('is_delete',0)->where('status',1)->value('sum(money)');
        $yearExpenditure = $ment->where('is_delete',0)->where('status',1)->whereTime('create_time','year')->value('sum(money)');
        $sumYearExpenditure = $ment->where('is_delete',0)->where('status',1)->value('sum(money)');
        $this->assign([
            'res'=>$res,
            'weekVisits'=>$weekVisits,
            'sumWeekVisits'=>$sumWeekVisits,
            'weekExpenditure'=>$weekExpenditure,
            'sumWeekExpenditure'=>$sumWeekExpenditure,
            'monthExpenditure'=>$monthExpenditure,
            'sumMonthExpenditure'=>$sumMonthExpenditure,
            'yearExpenditure'=>$yearExpenditure,
            'sumYearExpenditure'=>$sumYearExpenditure,
        ]);
        return view();
    }
}